package principe.segregation;

/**
 * 接口隔离原则
 */
public class Segregation1 {

    public static void main(String[] args) {
        A a = new A();
        a.use1(new B());
        a.use2(new B());
        a.use3(new B());
        C c = new C();
        c.use1(new D());
        c.use4(new D());
        c.use5(new D());
    }
}


//接口
interface Interface1 {
    void operator1();

    void operator2();

    void operator3();

    void operator4();

    void operator5();

}

//类C
class B implements Interface1 {

    @Override
    public void operator1() {

    }

    @Override
    public void operator2() {

    }

    @Override
    public void operator3() {

    }

    @Override
    public void operator4() {

    }

    @Override
    public void operator5() {

    }
}

//类D
class D implements Interface1 {

    @Override
    public void operator1() {

    }

    @Override
    public void operator2() {

    }

    @Override
    public void operator3() {

    }

    @Override
    public void operator4() {

    }

    @Override
    public void operator5() {

    }
}

//类A使用到了类C的123接口
class A {
    public void use1(Interface1 i) {
        i.operator1();
    }

    public void use2(Interface1 i) {
        i.operator2();
    }

    public void use3(Interface1 i) {
        i.operator3();
    }
}

//类B使用了类C的345接口
class C {
    public void use1(Interface1 i) {
        i.operator1();
    }

    public void use4(Interface1 i) {
        i.operator4();
    }

    public void use5(Interface1 i) {
        i.operator5();
    }
}